from rest_framework import serializers

from headline.models import Article, Comment
from users.models import User


class FansSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = '__all__'


class ArticlesSerializer(serializers.ModelSerializer):
    class Meta:
        model = Article
        fields = '__all__'

#
# class SubsSerializer(serializers.ModelSerializer):
#     class Meta:
#         model = Article
#         fields = '__all__'


class UserSerializer(serializers.ModelSerializer):
    articles = ArticlesSerializer(many=True)
    fans = FansSerializer(many=True)

    class Meta:
        model = User
        fields = '__all__'


class SubsSerializer(serializers.ModelSerializer):
    user = UserSerializer()
    subs = ArticlesSerializer(many=True)

    class Meta:
        model = Comment
        fields = '__all__'


class CommentSerialzier(serializers.ModelSerializer):
    user = UserSerializer()
    subs = SubsSerializer(many=True)

    class Meta:
        model = Comment
        fields = '__all__'


class CollectedUser(serializers.ModelSerializer):
    # user = UserSerializer()

    class Meta:
        model = User
        fields = '__all__'


class ArticleSerializer(serializers.ModelSerializer):
    # user = UserSerializer()
    collected_users = CollectedUser(many=True)
    comments = CommentSerialzier(many=True)

    class Meta:
        model = Article
        fields = '__all__'
